package com.yupi.yu_picture.model.enums;

import cn.hutool.core.util.ObjUtil;
import lombok.Getter;

@Getter
public enum UserRoleEnum {
    User("用户","user"),
    Admin("管理员","admin");

    UserRoleEnum(String text, String value) {
        this.text = text;
        this.value = value;
    }

    private String text;
    private String value;

    //编写一个方法获取特定角色枚举类
    public static UserRoleEnum getUserRoleEnum(String value){
        if (ObjUtil.isEmpty(value)){
            return null;
        }
        for (UserRoleEnum userRoleEnum:UserRoleEnum.values()){
            if (userRoleEnum.value.equals(value)){
                return userRoleEnum;
            }
        }
        return null;
    }
}
